const TarotCard = artifacts.require("TarotCard");

/*
 * uncomment accounts to access the test accounts made available by the
 * Ethereum client
 * See docs: https://www.trufflesuite.com/docs/truffle/testing/writing-tests-in-javascript
 */
contract("TarotCard", function (accounts) {
  it("should assert true", async function () {
    await TarotCard.deployed();
    return assert.isTrue(true);
  });
  
  it("should mint 26 coin, 0...25", async function () {
    const instance = await TarotCard.deployed();
    await instance.mint({from: accounts[0]});
    const balance = await instance.balanceOf(accounts[0]);
    assert.equal(balance, 26);
  });

    
  it("get account[0]'s token", async function () {
    const instance = await TarotCard.deployed();
    let balances = await instance.getOwnedTokenIds({from: accounts[0]});
    Object.values(balances).forEach((item) => {
      console.log(item.toNumber());
    })
    assert.equal(balances.length, 26);
  });

  it("transfer token", async function () {
    const instance = await TarotCard.deployed();
    await instance.transfer(accounts[1], 22, {from: accounts[0]});

    const balance1 = await instance.balanceOf(accounts[0]);
    let balances = await instance.getOwnedTokenIds({from: accounts[0]});
    Object.values(balances).forEach((item) => {
      console.log(item.toNumber());
    })

    const balance2 = await instance.balanceOf(accounts[1]);
    let balances2 = await instance.getOwnedTokenIds({from: accounts[1]});
    Object.values(balances2).forEach((item) => {
      console.log(item.toNumber());
    })
    

    assert.equal(balance1, 25);
    assert.equal(balance2, 1);
  });
});
